var newlist;
document.addEventListener('plusready',function(){
	showWating();
	$.ajax({
		type:"get",
		url:apiRoot+"?m=home&c=article&a=ancient",
		success :function(data){
			if(data){
				plus.storage.setItem('antlists',data);
				newlist = $.parseJSON(data);
				oldList(newlist);
			}
		},
		error : function (e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
	$('.search').on('input paste', function(e) {
		var search = $('.search').val();
		if(!search.trim()){
			oldList(newlist);
			return;
		}
		if(newlist.length > 0){
			$('.antlists .antlist').each(function(k, v) {
				var _this = $(this);
				var name = _this.text();
				if(name.indexOf(search) >= 0){
					_this.show();
				}else{
					_this.hide();
				}
			})
		}
	})
},false)
function oldList(arr){
	var list = '';
	$.each(arr, function(k,v) {
		list += '<div class="mui-table-view mui-table-view-cell antlist" data-id="'+v.aid+'">'+v.title+'</div>';
	});
	$('.antlists').html(list);
	plus.nativeUI.closeWaiting();
	$('.antlist').on('click',function(){
		var id = $(this).attr('data-id');
		console.log(id);
		goNewPage('home-old-method.html',{aid:id});
	})
}
